#ifndef AUTHWIDGET_H
#define AUTHWIDGET_H

#include "MessageType.h"
#include "mytcpsocket.h"
#include <QWidget>
#include <QLineEdit>
#include <QStackedWidget>
#include <QPushButton>

class AuthWidget : public QWidget
{
    Q_OBJECT

public:
    AuthWidget(QWidget *parent = nullptr);
    ~AuthWidget();

public slots:
    void handleLogin();
    void handleRegister();
    void handleLoginPacket(const Packet& packet);
    void handleSignupPacket(const Packet& packet);
    void switchToLogin();
    void switchToRegister();

private:
    void initUI();
    void initConnections();

    MyTcpSocket *clientTcpSocket;

    // 堆栈窗口管理登录和注册页面
    QStackedWidget *stackedWidget;

    // 登录页面控件
    QWidget *loginPage;
    QLineEdit *loginUsername;
    QLineEdit *loginPassword;
    QPushButton *loginButton;
    QPushButton *toRegisterButton;

    // 注册页面控件
    QWidget *registerPage;
    QLineEdit *registerUsername;
    QLineEdit *registerPassword;
    QLineEdit *registerPasswordConfirm;
    QPushButton *registerButton;
    QPushButton *toLoginButton;
};

#endif // AUTHWIDGET_H
